home *** CD-ROM | disk | FTP | other *** search
Wrap
Text File | 2009-12-13 | 43.5 KB | 1,482 lines
//------------------------------------------------------------------------------------------- // Social & Bookmarking services module. //------------------------------------------------------------------------------------------- const Cc = Components.classes; const Ci = Components.interfaces; var EXPORTED_SYMBOLS = ["samfind_modsbservices"]; var samfind_modsbservices_json = { JSON : null }; Components.utils.import("resource://samfind/JSON.jsm", samfind_modsbservices_json); Components.utils.import("resource://samfind/samfind_modutils.jsm"); var samfind_modsbservices = { _services : null, _services_dynamic : null, _init : function() { samfind_modsbservices._services = { aim : "AIM Share", amazon : "Amazon Wishlist", allvoices : "Allvoices", ask : "Ask", attentionmeter : "AttentionMeter", ballhype : "BallHype", barrapunto : "Barrapunto", bebo : "Bebo", bitly : "bit.ly", bizsugar : "bizSugar", blinklist : "BlinkList", blogger : "Blogger", bloglines : "Bloglines", blogmemesfr : "BlogMemes.fr", bookmarksfr : "Bookmarks.fr", bx : "Business Exchange", care2 : "Care2", citeulike : "CiteULike", cliqset : "Cliqset", connotea : "Connotea", current : "Current", dailyme : "DailyMe", delicious : "Delicious", designbump : "Design Bump", designfloat : "Design Float", digg : "Digg", diggita : "Diggita", diigo : "Diigo", dotnetkicks : "DotNetKicks", dropjack : "Dropjack", dzone : "DZone", ekudos : "eKudos", email : "Email to a friend", evernote : "Evernote", facebook : "Facebook", fark : "Fark", faves : "Faves", favoritus : "Favoritus", fnews : "Fnews", followup : "FollowUp", foxiewire : "FoxieWire", fresqui : "Fresqui", friendfeed : "FriendFeed", fsdaily : "FSDaily", funp : "Funp", gabbr : "Gabbr", gather : "Gather", globalgrind : "Global Grind", gmail : "Gmail", googlebookmarks : "Google Bookmarks", googlenotebook : "Google Notebook", googlereader : "Google Reader", hatena : "Hatena", healthranker : "Health Ranker", hellotxt : "HelloTxt", hemidemi : "HEMiDEMi", hipstr : "hipstr", hotmail : "Hotmail", hyves : "Hyves.nl", identica : "Identi.ca", indianpad : "IndianPad", instapaper : "Instapaper", isgd : "is.gd", jumptags : "Jumptags", kaboodle : "Kaboodle", kirtsy : "Kirtsy", laterthis : "LaterThis", linkarena : "linkARENA", linkagogo : "linkaGoGo", linkninja : "Link Ninja", linkedin : "LinkedIn", live : "Live", livejournal : "LiveJournal", lunch : "Lunch", meneame : "Meneame", misterwong : "Mister Wong", mixx : "Mixx", mozillaca : "Mozillaca", multiply : "Multiply", myaol : "MyAOL", myshare : "MyShare", myspace : "MySpace", n4g : "N4G", netvibes : "Netvibes", netvouz : "Netvouz", newstrust : "NewsTrust", newsvine : "Newsvine", nujij : "NUjij", oknotizie : "OKNOtizie", oneviewcom : "oneview.com", oneviewde : "oneview.de", orkut : "Orkut", picnik : "Picnik", pingfm : "Ping.fm", plurk : "Plurk", posterous : "Posterous", propeller : "Propeller", pusha : "Pusha", quantcast : "Quantcast", reddit : "Reddit", scoopeo : "Scoopeo", scoopit : "Scoopit", segnalo : "Segnalo", shoutwire : "ShoutWire", simpy : "Simpy", slashdot : "Slashdot", smaknews : "SmakNews", socialmedian : "socialmedian", socialogs : "Socialogs", soup : "Soup", sphere : "Sphere It!", sphinn : "Sphinn", spring : "Spring", spurl : "Spurl", squidoo : "Squidoo", strands : "Strands", streakr : "Streakr", stumble : "Stumble!", stumbleupon : "StumbleUpon", stumpedia : "Stumpedia", stylehive : "Stylehive", supr : "Su.pr", swik : "SWiK", symbaloo : "Symbaloo", tailrank : "Tailrank", tbuzz : "TBUZZ", technorati : "Technorati", thisnext : "ThisNext", tinyurl : "TinyURL", tipd : "Tip'd", trim2 : "tr.im", truemors : "Truemors", tumblr : "Tumblr", twackle : "Twackle", twiddla : "Twiddla", twine : "Twine", twitter : "Twitter", viadeo : "Viadeo", visualize : "vi.sualize.us", weheartit : "We heart it", wikio : "Wikio", wists : "Wists", wordpress : "WordPress", xanga : "Xanga", xerpi : "Xerpi", yahoobookmarks : "Yahoo! Bookmarks", yahoobuzz : "Yahoo! Buzz", yammer : "Yammer", ycombinator : "Y Combinator", yigg : "YiGG", yoolink : "Yoolink", youmob : "YouMob" }; // samfind_modsbservices._services_dynamic = new Array( "delicious", "digg", "reddit" ); }, createButtons : function(services, parent, dataProvider, sidebarOpener) { var dynamic = false; var space = samfind_modutils._pref_branch.getCharPref("social.space"); for (var i=0; i<services.length; ++i) { var service = services[i]; switch (service) { case "delicious": case "digg": case "reddit": { dynamic = true; } default: { samfind_modsbservices.createButton(service, parent, dataProvider, sidebarOpener); } } if (i != services.length - 1 && space != "small") { var spacer = parent.appendChild(parent.ownerDocument.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "spacer")); spacer.width = (space == "medium" ? 3 : 6); } } return dynamic; }, createButton : function(service, parent, dataProvider, sidebarOpener) { var service_text = samfind_modsbservices._services[service]; var toolbarbutton = parent.appendChild(parent.ownerDocument.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "toolbarbutton")); toolbarbutton.setAttribute("id", "samfind-" + service); toolbarbutton.setAttribute("class", "samfindsb sb-" + service); toolbarbutton.setAttribute("dataprovider", dataProvider); var command_share = "samfind_modsbservices.share(" + dataProvider + ", '" + service + "');"; switch (service) { case "amazon": { toolbarbutton.setAttribute("tooltiptext", "Save to your Amazon Wishlist"); toolbarbutton.setAttribute("oncommand", command_share); } break; case "attentionmeter": { toolbarbutton.setAttribute("tooltiptext", "Compare with AttentionMeter"); toolbarbutton.setAttribute("oncommand", command_share); } break; case "bitly": { toolbarbutton.setAttribute("tooltiptext", "Shorten URL with bit.ly"); var login = samfind_modutils._pref_branch.getCharPref("bitly.user.login"); var apikey = samfind_modutils._pref_branch.getCharPref("bitly.user.apikey"); if (login.length && apikey.length) { toolbarbutton.setAttribute("oncommand", (sidebarOpener == null ? "toggleSidebar('samfind-bitly-view', true);" : (sidebarOpener + "('bitly', event);"))); } else { toolbarbutton.setAttribute("oncommand", command_share); } } break; case "email": { toolbarbutton.setAttribute("tooltiptext", service_text); toolbarbutton.setAttribute("oncommand", (sidebarOpener == null ? "toggleSidebar('samfind-email-view', true);" : (sidebarOpener + "('email', event);"))); } break; case "identica": { toolbarbutton.setAttribute("tooltiptext", "Share with Identi.ca"); toolbarbutton.setAttribute("oncommand", (sidebarOpener == null ? "toggleSidebar('samfind-identica-view', true);" : (sidebarOpener + "('identica', event);"))); } break; case "isgd": { toolbarbutton.setAttribute("tooltiptext", "Shorten URL with is.gd"); toolbarbutton.setAttribute("oncommand", command_share); } break; case "n4g": { toolbarbutton.setAttribute("tooltiptext", "Tips N4G"); toolbarbutton.setAttribute("oncommand", command_share); } break; case "quantcast": { toolbarbutton.setAttribute("tooltiptext", "Quantify with Quantcast"); toolbarbutton.setAttribute("oncommand", command_share); } break; case "sphere": case "stumble": { toolbarbutton.setAttribute("tooltiptext", service_text); toolbarbutton.setAttribute("oncommand", command_share); } break; case "supr": { toolbarbutton.setAttribute("tooltiptext", "Shorten URL with Su.pr"); toolbarbutton.setAttribute("oncommand", command_share); } break; case "tinyurl": { toolbarbutton.setAttribute("tooltiptext", "Make TinyURL!"); toolbarbutton.setAttribute("oncommand", command_share); } break; case "trim2": { toolbarbutton.setAttribute("tooltiptext", "Shorten URL with tr.im"); toolbarbutton.setAttribute("oncommand", command_share); } break; case "twitter": { toolbarbutton.setAttribute("tooltiptext", "Share with Twitter"); toolbarbutton.setAttribute("oncommand", (sidebarOpener == null ? "toggleSidebar('samfind-twitter-view', true);" : (sidebarOpener + "('twitter', event);"))); } break; case "wordpress": { toolbarbutton.setAttribute("tooltiptext", "Press to " + samfind_modutils._pref_branch.getCharPref("wordpress.blogname")); toolbarbutton.setAttribute("oncommand", command_share); } break; default: { toolbarbutton.setAttribute("tooltiptext", "Share with " + service_text); toolbarbutton.setAttribute("oncommand", command_share); } } }, resetDynamicInfo : function(button, service) { var width = button.boxObject.width; button.removeAttribute("label"); var total_width = (width - button.boxObject.width); switch (service) { case "digg": { button.setAttribute("tooltiptext", "Share with Digg"); } break; case "reddit": { button.setAttribute("tooltiptext", "Share with Reddit"); } break; } button.setAttribute("oncommand", "samfind_modsbservices.share(" + button.getAttribute("dataprovider") + ", '" + service + "');"); return total_width; }, fetchDynamicInfo : function(service, href, button, fetchedObserver) { switch (service) { case "delicious": { samfind_modsbservices.getDeliciousSaves(href, button, fetchedObserver); } break; case "digg": { samfind_modsbservices.getDiggs(href, button, fetchedObserver); } break; case "reddit": { samfind_modsbservices.getRedditPoints(href, button, fetchedObserver); } break; } }, getDeliciousSaves : function(href, button, fetchedObserver) { try { var xhr = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance(Ci.nsIXMLHttpRequest); xhr.open("GET", "http://feeds.delicious.com/v2/json/urlinfo/data?url=" + href, true); var timeout = samfind_modutils.setXhrAbortTimeout(xhr, 10000); xhr.onreadystatechange = function(e) { if (xhr.readyState == 4) { timeout.cancel(); timeout = null; if (xhr.status == 200) { var json_obj = samfind_modsbservices_json.JSON.parse(xhr.responseText); var info = json_obj[0]; var saves = 0; if (info) { saves = info.total_posts; } info = null; json_obj = null; if (saves > 0) { button.setAttribute("label", "(" + saves + ")"); if (fetchedObserver != null) { fetchedObserver.dynamicInfoFetched(); } } } xhr = null; } } xhr.send(null); } catch (e) {} }, getDiggs : function(href, button, fetchedObserver) { try { var xhr = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance(Ci.nsIXMLHttpRequest); xhr.open("GET", "http://services.digg.com/stories?count=1&type=json&appkey=http://samfind.com&link=" + href, true); var timeout = samfind_modutils.setXhrAbortTimeout(xhr, 10000); xhr.onreadystatechange = function(e) { if (xhr.readyState == 4) { timeout.cancel(); timeout = null; if (xhr.status == 200) { var json_obj = samfind_modsbservices_json.JSON.parse(xhr.responseText); var total_stories = json_obj.total; var diggs = 0; var comments; var href; if (total_stories > 0) { var story_info = json_obj.stories[0]; if (story_info) { diggs = story_info.diggs; comments = story_info.comments; href = story_info.href; } } json_obj = null; if (diggs > 0) { button.setAttribute("label", "(" + diggs + ")"); button.setAttribute("tooltiptext", diggs + " diggs, " + comments + " comments, click to digg and comment"); button.setAttribute("oncommand", "samfind_utils.openTab('" + href + "', false, null, event);"); if (fetchedObserver != null) { fetchedObserver.dynamicInfoFetched(); } } } xhr = null; } } xhr.send(null); } catch (e) {} }, getRedditPoints : function(href, button, fetchedObserver) { try { var xhr = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance(Ci.nsIXMLHttpRequest); xhr.open("GET", "http://www.reddit.com/api/info.json?count=1&url=" + href, true); var timeout = samfind_modutils.setXhrAbortTimeout(xhr, 10000); xhr.onreadystatechange = function(e) { if (xhr.readyState == 4) { timeout.cancel(); timeout = null; if (xhr.status == 200) { var json_obj = samfind_modsbservices_json.JSON.parse(xhr.responseText); var data = json_obj.data; var points = 0; var id; if (data) { var children = data.children; if (children && children.length) { for (var i=0; i<children.length; ++i) { data = children[i].data; if (data && data.score > 0) { points = data.score; id = data.id; break; } } } } json_obj = null; if (points > 0) { button.setAttribute("label", "(" + points + ")"); button.setAttribute("tooltiptext", points + " points, click to vote and comment"); button.setAttribute("oncommand", "samfind_utils.openTab('http://www.reddit.com/comments/" + id + "', false, null, event);"); if (fetchedObserver != null) { fetchedObserver.dynamicInfoFetched(); } } } xhr = null; } } xhr.send(null); } catch (e) {} }, share : function(dataProvider, aService) { var location = dataProvider.getLocation(); if (location == null) { return; } else { location = encodeURIComponent(location); } var title = dataProvider.getTitle(); if (title.length) { title = encodeURIComponent(title); } var selection = dataProvider.getSelection(); if (selection.length) { selection = encodeURIComponent(selection); } // var url = null; var win = samfind_modutils.getWindow(); // switch (aService) { case "aim": { url = "http://share.aim.com/share/?url=" + location + "&title=" + title; } break; case "amazon": { url = "http://www.amazon.com/wishlist/add?u=" + location + "&t=" + title; } break; case "allvoices": { url = "http://www.allvoices.com/post_event?url=" + location + "&title=" + title; } break; case "ask": { url = "http://myjeeves.ask.com/mysearch/BookmarkIt?v=1.2&t=webpages&url=" + location + "&title=" + title + "&abstext=" + selection; } break; case "attentionmeter": { var decoded = decodeURIComponent(location); var decoded_uri = samfind_modutils._io_service.newURI(decoded, null, null); var host = decoded_uri.host; if (host.indexOf("www.") == 0) { host = host.substring(4); } url = "http://www.attentionmeter.com/bookmarklet.php?d1=" + host; } break; case "ballhype": { url = "http://ballhype.com/post/url/?url=" + location + "&title=" + title; } break; case "barrapunto": { url = "http://barrapunto.com/submit.pl?subj=" + title + "&story=" + location; } break; case "bebo": { url = "http://www.bebo.com/c/share?Url=" + location + "&Title=" + title; } break; case "bitly": { url = "http://bit.ly/?url=" + location; } break; case "bizsugar": { url = "http://www.bizsugar.com/submit.php?url=" + location; } break; case "blinklist": { url = "http://blinklist.com/blink?u=" + location + "&t=" + title + "&d=" + selection + "&v=2"; } break; case "blogger": { url = "http://www.blogger.com/blog_this.pyra?u=" + location + "&n=" + title + "&t=" + selection; } break; case "bloglines": { url = "http://www.bloglines.com/sub/" + decodeURIComponent(location); } break; case "blogmemesfr": { url = "http://www.blogmemes.fr/post.php?url=" + location + "&title=" + title; } break; case "bookmarksfr": { url = "http://www.bookmarks.fr/favoris/AjoutFavori?action=add&address=" + location + "&title=" + title + "&description=" + selection; } break; case "bx": { url = "http://bx.businessweek.com/api/add-article-to-bx.tn?url=" + location; } break; case "care2": { url = "http://www.care2.com/news/compose?share[link_url]=" + location + "&share[title]=" + title; } break; case "citeulike": { url = "http://www.citeulike.org/posturl?bml=nopopup&url=" + location + "&title=" + title; } break; case "cliqset": { win.getBrowser().loadURI("javascript:void((function(){var%20b=document.body;if(b){var%20e=document.createElement('script');e.setAttribute('type','text/javascript');e.setAttribute('src','http://cliqset.com/bookmarklet/bookmarklet.js');b.appendChild(e);}})());"); } break; case "connotea": { url = "http://www.connotea.org/add?continue=return&uri=" + location + "&title=" + title + "&description=" + selection; } break; case "current": { url = "http://current.com/clipper.htm?url=" + location + "&title=" + title; } break; case "dailyme": { url = "http://dailyme.com/bookmarklet?u=" + location + "&t=" + title; } break; case "designbump": { url = "http://designbump.com/node/add/drigg?url=" + location; } break; case "designfloat": { url = "http://designfloat.com/submit.php?url=" + decodeURIComponent(location); } break; case "delicious": { url = "http://delicious.com/save?url=" + location + "&title=" + title + "¬es=" + selection + "&jump=yes"; } break; case "digg": { url = "http://digg.com/submit?phase=2&url=" + location + "&title=" + title + "&bodytext=" + selection; } break; case "diggita": { url = "http://www.diggita.it/submit.php?url=" + location + "&title=" + title; } break; case "diigo": { win.content.document.location = "http://www.diigo.com/post?url=" + location + "&title=" + title + "&desc=" + selection; win.content.focus(); } break; case "dotnetkicks": { url = "http://www.dotnetkicks.com/kick/?url=" + location + "&title=" + title; } break; case "dropjack": { url = "http://www.dropjack.com/submit.php?url=" + location + "&title=" + title; } break; case "dzone": { url = "http://www.dzone.com/links/add.html?url=" + location + "&title=" + title; } break; case "ekudos": { url = "http://www.ekudos.nl/artikel/nieuw?url=" + location + "&title=" + title + "&desc=" + selection; } break; case "evernote": { url = "http://www.evernote.com/clip.action?url=" + location + "&title=" + title; } break; case "facebook": { url = "http://www.facebook.com/share.php?u=" + location + "&t=" + title; } break; case "fark": { url = "http://cgi.fark.com/cgi/fark/farkit.pl?u=" + location + "&h=" + title; } break; case "faves": { url = "http://faves.com/Authoring.aspx?u=" + location + "&t=" + title; } break; case "favoritus": { url = "http://www.favoritus.com/add.php?lang=EN&gettitle=" + title + "&getlink=" + location; } break; case "fnews": { url = "http://fnews.az/node/add/drigg?url=" + location + "&title=" + title + "&body=" + selection; } break; case "followup": { url = "http://www.followup.cc/bookmark.php?url=" + location + "&title=" + title; } break; case "foxiewire": { url = "http://www.foxiewire.com/?q=submit&url=" + location + "&title=" + title + "&body=" + selection; } break; case "fresqui": { url = "http://fresqui.com/enviar?url=" + location + "&title=" + title; } break; case "friendfeed": { url = "http://friendfeed.com/?url=" + location + "&title=" + title; } break; case "fsdaily": { url = "http://www.fsdaily.com/submit?url=" + location + "&title=" + title; } break; case "funp": { url = "http://funp.com/pages/submit/add.php?title=" + title + "&url=" + location; } break; case "gabbr": { url = "http://www.gabbr.com/submit/?bookurl=" + location; } break; case "gather": { url = "http://www.gather.com/sharePosts.action?title=" + title + "&body=" + location; } break; case "globalgrind": { url = "http://globalgrind.com/submission/submit.aspx?url=" + location + "&type=Article&title=" + title; } break; case "gmail": { url = "http://mail.google.com/mail/?ui=1&view=cm&fs=1&tf=1&to=&su=" + title + "&body=Link: " + location + "%0D%0A%0D%0A" + selection + "%0D%0A%0D%0A" + "%28via samfind Bookmarks Bar%29"; } break; case "googlebookmarks": { url = "http://www.google.com/bookmarks/mark?op=add&bkmk=" + location + "&title=" + title + "&annotation=" + selection; } break; case "googlenotebook": { win.getBrowser().loadURI("javascript:(function(){var%20w=window;var%20d=document;var%20g=w.open('about:blank','gnotesWin','location=0,menubar=0,scrollbars=0,status=0,toolbar=0,width=300,height=300,resizable=1');var%20s=d.createElement('script');s.setAttribute('src','http://www.google.com/notebook/bookmarkletPoster?zx='+(new%20Date()).valueOf());d.body.appendChild(s);w.setTimeout(function(){w.blur();g.focus();},%20100)}).call({});"); } break; case "googlereader": { win.getBrowser().loadURI( "javascript:var%20b=document.body;var%20GR________bookmarklet_domain='https://www.google.com';if(b&&!document.xmlVersion){void(z=document.createElement('script'));void(z.src='https://www.google.com/reader/ui/link-bookmarklet.js');void(b.appendChild(z));}else{}"); } break; case "hatena": { url = "http://b.hatena.ne.jp/bookmarklet?url=" + location + "&btitle=" + title; } break; case "healthranker": { url = "http://www.healthranker.com/submit.php?url=" + location + "&title=" + title; } break; case "hellotxt": { url = "http://hellotxt.com/?status=" + title + "%20" + location; } break; case "hemidemi": { url = "http://www.hemidemi.com/user_bookmark/new?title=" + title + "&url=" + location + "&description=" + selection + "&via=samfind%20Bookmarks%20Bar"; } break; case "hipstr": { url = "http://hipstr.com/submit.php?burl=" + location; } break; case "hotmail": { url = "http://mail.live.com/default.aspx?rru=compose%3Fsubject%3D" + encodeURIComponent(escape(decodeURIComponent(title))) + "%26body%3DLink: " + encodeURIComponent(escape(decodeURIComponent(location))) + "%0D%0A%0D%0A" + encodeURIComponent(escape(decodeURIComponent(selection))) + "%0D%0A%0D%0A" + "%28via samfind Bookmarks Bar%29"; } break; case "hyves": { url = "http://www.hyves.nl/profilemanage/add/tips/?name=" + title + "&text=" + location; } break; case "identica": { url = "http://identi.ca/?action=newnotice&status_textarea=" + title + "%20" + location; } break; case "indianpad": { url = "http://www.indianpad.com/submit.php?url=" + location; } break; case "instapaper": { url = "http://www.instapaper.com/b?u=" + location + "&t=" + title; } break; case "isgd": { url = "http://is.gd/create.php?longurl=" + location; } break; case "jumptags": { url = "http://www.jumptags.com/add/?url=" + location + "&title=" + title; } break; case "kaboodle": { url = "http://www.kaboodle.com/za/selectpage?p_pop=false&pa=url&u=" + location; } break; case "kirtsy": { url = "http://www.kirtsy.com/submit.php?url=" + location; } break; case "linkagogo": { url = "http://www.linkagogo.com/go/AddNoPopup?url=" + location + "&title=" + title + "&comments=" + selection; } break; case "linkninja": { url = "http://linkninja.com.br/enviar_link.php?story_url=" + location + "&story_title=" + title + "&story_desc=" + selection; } break; case "laterthis": { win.content.document.location = "http://laterthis.com/post?stand_alone=true&link_url=" + location + "&link_title=" + title + "&link_comment=" + selection; win.content.focus(); } break; case "linkarena": { url = "http://linkarena.com/bookmarks/addlink/?url=" + location + "&title=" + title; } break; case "linkedin": { url = "http://www.linkedin.com/shareArticle?mini=true&url=" + location + "&title=" + title + "&summary=" + selection + "&source=Posted via samfind Bookmarks Bar"; } break; case "live": { win.content.document.location = "https://favorites.live.com/quickadd.aspx?marklet=1&mkt=en-us&url=" + location + "&title=" + title; win.content.focus(); } break; case "livejournal": { url = "http://www.livejournal.com/update.bml?subject=" + title + "&event=" + location + escape(" (via samfind Bookmarks Bar) \n\n") + selection; } break; case "lunch": { url = "http://www.lunch.com//Bookmarklet/LunchThis.html?url=" + location + "&title=" + title; } break; case "meneame": { url = "http://meneame.net/submit.php?url=" + location + "&title=" + title; } break; case "misterwong": { url = "http://www.mister-wong.com/index.php?action=addurl&bm_url=" + location + "&bm_description=" + title; } break; case "mixx": { url = "http://www.mixx.com/submit?page_url=" + location; } break; case "mozillaca": { url = "http://mozillaca.com/index.php?action=newnotice&status_textarea=\"" + title + "\" from " + location; } break; case "multiply": { url = "http://multiply.com/gus/journal/compose/?url=" + location + "&subject=" + title + "&body=" + selection; } break; case "myaol": { url = "http://favorites.my.aol.com/ffclient/AddBookmark?url=" + location + "&title=" + title + "&favelet=true"; } break; case "myshare": { url = "http://myshare.url.com.tw/index.php?func=newurl&url=" + location + "&desc=" + title; } break; case "myspace": { url = "http://www.myspace.com/Modules/PostTo/Pages/?l=3&u=" + location + "&t=" + title + "&c=" + selection + "<p>Posted via <a href=\"https://addons.mozilla.org/en-US/firefox/addon/9866\">samfind Bookmarks Bar</a></p>"; } break; case "n4g": { url = "http://www.n4g.com/tips.aspx?url=" + location + "&title=" + title; } break; case "netvibes": { url = "http://www.netvibes.com/share?url=" + location + "&title=" + title; } break; case "netvouz": { url = "http://netvouz.com/action/submitBookmark?url=" + location + "&title=" + title; } break; case "newstrust": { url = "http://newstrust.net/submit?url=" + location + "&title=" + title + "&bookmarklet=1"; } break; case "newsvine": { url = "http://www.newsvine.com/_tools/seed&save?u=" + location + "&h=" + title; } break; case "nujij": { url = "http://nujij.nl/jij.lynkx?t=" + title + "&u=" + location + "&b=" + selection; } break; case "oknotizie": { url = "http://oknotizie.alice.it/post?url=" + location + "&title=" + title; } break; case "oneviewcom": { url = "http://www.oneview.com/quickadd/neu/addBookmark.jsf?URL=" + location + "&title=" + title; } break; case "oneviewde": { url = "http://www.oneview.de/add/?URL=" + location + "&title=" + title; } break; case "orkut": { url = "http://promote.orkut.com/preview?src=bkmrklt&v=1&nt=orkut.com&du=" + location + "&tt=" + title + "&rdrinl=1"; } break; case "picnik": { url = "http://www.picnik.com/?import=" + location; } break; case "pingfm": { url = "http://ping.fm/ref/?link=" + location + "&title=" + title; } break; case "plurk": { url = "http://www.plurk.com/m?content=" + location + "&qualifier=shares"; } break; case "posterous": { url = "http://posterous.com/share?linkto=" + location + "&title=" + title; } break; case "propeller": { url = "http://www.propeller.com/story/submit/?url=" + location + "&title=" + title; } break; case "pusha": { url = "http://www.pusha.se/posta?url=" + location + "&title=" + title + "&description=" + selection; } break; case "quantcast": { var decoded = decodeURIComponent(location); var decoded_uri = samfind_modutils._io_service.newURI(decoded, null, null); var host = decoded_uri.host; if (host.indexOf("www.") == 0) { host = host.substring(4); } url = "http://www.quantcast.com/" + host; } break; case "reddit": { url = "http://reddit.com/submit?url=" + location + "&title=" + title; } break; case "scoopeo": { url = "http://www.scoopeo.com/scoop/new?newurl=" + location + "&title=" + title + "&content=" + selection; } break; case "scoopit": { url = "http://www.scoopit.co.nz/submit.php?url=" + location; } break; case "segnalo": { url = "http://segnalo.virgilio.it/post.html.php?url=" + location + "&title=" + title +"&descr" + selection; } break; case "shoutwire": { url = "http://www.shoutwire.com/?p=submit&link=" + location; } break; case "simpy": { url = "http://www.simpy.com/simpy/LinkAdd.do?href=" + location + "&title=" + title + "¬e=" + selection + "&src=bookmarklet"; } break; case "slashdot": { url = "http://slashdot.org/slashdot-it.pl?op=basic&url=" + location; } break; case "smaknews": { url = "http://smaknews.com/submit.php?url=" + location; } break; case "socialmedian": { url = "http://www.socialmedian.com/bookmarker?u=" + location + "&t=" + title + "&s=" + selection; } break; case "socialogs": { url = "http://socialogs.com/add_story.php?story_url=" + location + "&story_title=" + title + "&story_desc=" + selection; } break; case "soup": { var d = win.content.document; var di = win.content.document.images; var dom = win.content.document.location.href.match(/(.*)\/.*$/)[1]; var i = ''; for (var n=0; n<di.length; n++) { if (di[n].offsetWidth*di[n].offsetHeight > 1400) { i += di[n].src.replace(dom, '@@') + '|' + di[n].offsetWidth + '|' + di[n].offsetHeight +','; } } url = "http://www.soup.io/bookmarklet?v=5&u=" + location + "&t=" + title + "&s=" + location + "&dom=" + encodeURIComponent(dom) + "&i=" + encodeURIComponent(i); } break; case "sphere": { url = "http://www.sphere.com/search/blogs/?q=sphereit:" + location + "&title=" + title; } break; case "sphinn": { url = "http://sphinn.com/submit.php?url=" + location + "&title=" + title; } break; case "spring": { win.getBrowser().loadURI("javascript:(function(){SP_HOST='http://springpadit.com';try{var%20x=document.createElement('SCRIPT');x.type='text/javascript';x.src=SP_HOST+'/public/clipper_inline.js?'+(new%20Date().getTime()/100000);document.getElementsByTagName('head')[0].appendChild(x);}catch(e){location.href=SP_HOST+'/clip.action?url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title);}})();"); } break; case "spurl": { url = "http://www.spurl.net/spurl.php?url=" + location + "&title=" + title; } break; case "squidoo": { url = "http://www.squidoo.com/lensmaster/bookmark?" + location; } break; case "strands": { url = "http://www.strands.com/tools/share/webpage?title=" + title + "&url=" + location; } break; case "streakr": { url = "http://www.streakr.com/mystreakr/emailfriend.aspx?SiteURL=" + location; } break; case "stumble": { url = "http://www.stumbleupon.com/su/"; } break; case "stumbleupon": { url = "http://www.stumbleupon.com/submit?url=" + location + "&title=" + title; } break; case "stumpedia": { url = "http://www.stumpedia.com/submit?url=" + location + "&title=" + title; } break; case "stylehive": { url = "http://www.stylehive.com/savebookmark/index.htm?url=" + location; } break; case "supr": { win.getBrowser().loadURI("javascript:var%20e=document.createElement('script');e.setAttribute('type','text/javascript');e.setAttribute('src','http://su.pr/supr_shortcut.php?action=js_post');document.body.appendChild(e);void(0);"); } break; case "swik": { url = "http://stories.swik.net/?bookmarklet=v1&submitUrl&url=" + location + "&title=" + title + "&description=" + selection; } break; case "symbaloo": { url = "http://www.symbaloo.com/en/add/?url=" + location + "&title=" + title; } break; case "tailrank": { url = "http://tailrank.com/share/?link_href=" + location + "&title=" + title; } break; case "tbuzz": { win.getBrowser().loadURI("javascript:(function(){_tbuzz_css=document.createElement('LINK');_tbuzz_css.rel='stylesheet';_tbuzz_css.href='http://tbuzz.arc90.com/css/tbuzz';_tbuzz_css.href+=(document.all%20&&%20!window.opera%20&&%20window.XMLHttpRequest%20&&%20document.compatMode!='CSS1Compat')%20?%20'IE7.css?x='%20:%20'.css?x=';_tbuzz_css.href+=(Math.random());_tbuzz_css.type='text/css';document.getElementsByTagName('head')[0].appendChild(_tbuzz_css);_tbuzz_script=document.createElement('SCRIPT');_tbuzz_script.type='text/javascript';_tbuzz_script.src='http://tbuzz.arc90.com/js/tbuzz.bookmarklet.js?x='+(Math.random());document.getElementsByTagName('head')[0].appendChild(_tbuzz_script);})();"); } break; case "technorati": { url = "http://technorati.com/faves?add=" + location; } break; case "thisnext": { url = "http://www.thisnext.com/pick/new/submit/sociable/?url=" + location + "&name=" + title; } break; case "tinyurl": { url = "http://tinyurl.com/create.php?url=" + location; } break; case "tipd": { url = "http://tipd.com/submit.php?url=" + location; } break; case "trim2": { url = "http://tr.im/marklet?url=" + location; } break; case "truemors": { url = "http://truemors.nowpublic.com/post/?headline=" + title + "&truemor=" + selection + "%0D%0D%0A%3Ca href=%22" + location + "%22%3E%3C/a%3E"; } break; case "tumblr": { url = "http://www.tumblr.com/share?v=3&u=" + location + "&t=" + title + "&s=" + selection; } break; case "twackle": { url = "http://www.twackle.com/chicklet?site=" + location; } break; case "twiddla": { url = "http://www.twiddla.com/NewSession.aspx?url=" + escape(decodeURIComponent(location)) + "&title=" + escape(decodeURIComponent(title).substr(0, 50)); } break; case "twine": { url = "http://www.twine.com/bookmark/basic?u=" + location + "&t=" + title + "&v=3"; } break; case "twitter": { url = "http://twitter.com/home?status=" + title + "%20" + location + "&source=samfindtoolbar"; } break; case "viadeo": { url = "http://www.viadeo.com/shareit/share/?url=" + loation + "&title=" + title + "&encoding=UTF-8"; } break; case "visualize": { win.getBrowser().loadURI("javascript:(function(){function%20l(u,i){var%20d=document;if(!d.getElementById(i)){var%20s=d.createElement('script');s.src=u;s.id=i;d.body.appendChild(s);}}l('http://vi.sualize.us/js/visualizeus.js','visualizeus')})();"); } break; case "weheartit": { win.getBrowser().loadURI("javascript:void((function(){var%20e=document.createElement('script');e.setAttribute('type','text/javascript');e.setAttribute('charset','UTF-8');e.setAttribute('src','http://weheartit.com/bookmarklet.js');document.body.appendChild(e)})());"); } break; case "wikio": { url = "http://www.wikio.com/sharethis?url=" + location + "&title=" + title; } break; case "wists": { url = "http://wists.com/u.php?r=" + location + "&t=" + title; } break; case "wordpress": { win.getBrowser().loadURI("javascript:var%20d=document,w=window,e=w.getSelection,k=d.getSelection,x=d.selection,s=(e?e():(k)?k():(x?x.createRange().text:0)),f='https://" + samfind_modutils._pref_branch.getCharPref("wordpress.blogname") + "/wp-admin/press-this.php',l=d.location,e=encodeURIComponent,g=f+'?u=" + location + "&t=" + title + "&s=" + selection + "&v=2';function%20a(){if(!w.open(g,'t','toolbar=0,resizable=0,scrollbars=1,status=1,width=720,height=620,left=" + ((win.screen.availWidth - 720) / 2) + ",top=" + ((win.screen.availHeight - 620) / 2) + "')){l.href=g;}}setTimeout(a,0);void(0);"); } break; case "xanga": { url = "http://www.xanga.com/private/editorx.aspx?u=" + location + "&t=" + title; } break; case "xerpi": { url = "http://www.xerpi.com/favorite/post?url=" + location + "&title=" + title; } break; case "yahoobookmarks": { url = "http://bookmarks.yahoo.com/toolbar/savebm?u=" + location + "&t=" + title + "&d=" + selection + "&opener=bm&ei=UTF-8"; } break; case "yahoobuzz": { url = "http://buzz.yahoo.com/buzz?targetUrl=" + location + "&headline=" + title + "&summary=" + selection; } break; case "yammer": { url = "http://www.yammer.com/home/bookmarklet?bookmarklet_pop=0&v=1&u=" + location + "&t=" + title + "&s=" + selection; } break; case "ycombinator": { url = "http://news.ycombinator.com/submitlink?u=" + location + "&t=" + title; } break; case "yigg": { url = "http://www.yigg.de/neu?exturl=" + location + "&exttitle=" + title; } break; case "yoolink": { url = "http://www.yoolink.fr/addorshare?url_value=" + location + "&title=" + title; } break; case "youmob": { url = "http://youmob.com/startmob.aspx?mob=" + location; } break; } // if (url != null) { samfind_modutils.openTab(url, null); } }, shortenURL : function(url, observer) { var login = samfind_modutils._pref_branch.getCharPref("bitly.user.login"); if (login.length == 0) { login = "samfind"; } var apikey = samfind_modutils._pref_branch.getCharPref("bitly.user.apikey"); if (apikey.length == 0) { apikey = "R_5e58220fae38fe8a7b63d7bf0e73852a"; } // try { var xhr = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance(Ci.nsIXMLHttpRequest); xhr.open("GET", "http://api.bit.ly/shorten?version=2.0.1&longUrl=" + escape(url) + "&login=" + login + "&apiKey=" + apikey, true); var timeout = samfind_modutils.setXhrAbortTimeout(xhr, 10000); xhr.onreadystatechange = function(e) { if (xhr.readyState == 4) { timeout.cancel(); timeout = null; if (xhr.status == 200) { var json_obj = samfind_modsbservices_json.JSON.parse(xhr.responseText); if (json_obj.errorCode != 0) { observer.fail(); } else { var results = json_obj.results; for (var i in results) { var result = results[i]; if (result.errorCode) { observer.fail(); } else { observer.ok(result.shortUrl); } } results = null; } json_obj = null; } else { observer.fail(); } xhr = null; } }; xhr.send(null); } catch (e) { observer.fail(); } }, getTwitterAuth : function() { return samfind_modutils.getAuth("samfindtwitter", "samfindtwitter"); }, postToTwitter : function(update, auth, observer) { var post_param = "source=samfindtoolbar&status=" + encodeURIComponent(update); if (auth == null) { auth = samfind_modsbservices.getTwitterAuth(); } var xhr = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance(Ci.nsIXMLHttpRequest); xhr.open("POST", "http://twitter.com/statuses/update.json", true); xhr.setRequestHeader("Authorization", "Basic " + btoa(auth.username + ":" + auth.password)); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.setRequestHeader("Content-Length", post_param.length); var timeout = samfind_modutils.setXhrAbortTimeout(xhr, 10000); xhr.onreadystatechange = function() { if (xhr.readyState == 4) { timeout.cancel(); timeout = null; if (xhr.status == 200) { observer.ok(); } else { observer.fail(xhr.status); } xhr = null; } }; xhr.send(post_param); }, getIdenticaAuth : function() { return samfind_modutils.getAuth("samfindidentica", "samfindidentica"); }, postToIdentica : function(update, auth, observer) { var post_param = "status=" + encodeURIComponent(update); if (auth == null) { auth = samfind_modsbservices.getIdenticaAuth(); } var xhr = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance(Ci.nsIXMLHttpRequest); xhr.open("POST", "http://identi.ca/api/statuses/update.json", true); xhr.setRequestHeader("Authorization", "Basic " + btoa(auth.username + ":" + auth.password)); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.setRequestHeader("Content-Length", post_param.length); var timeout = samfind_modutils.setXhrAbortTimeout(xhr, 10000); xhr.onreadystatechange = function() { if (xhr.readyState == 4) { timeout.cancel(); timeout = null; if (xhr.status == 200) { observer.ok(); } else { observer.fail(xhr.status); } xhr = null; } }; xhr.send(post_param); } }; /** * Constructor. */ (function() { this._init(); }).apply(samfind_modsbservices);